dataSet = readTxt("/example/knapsack1.txt");
dataSet = dataSet.double("value").int("weight").int("count");
//================================================================================
//01背包
bagSize = 10;
println(dataSet.dpKnapsack(bagSize,dataSet.weight,1,dataSet.value));//1表示所有物品的最大份数都为1

//完全背包
bagSize = 10;
println(dataSet.dpKnapsack(bagSize,dataSet.weight,dataSet.value));
//================================================================================


dataSet = readTxt("/example/knapsack2.txt");
dataSet = dataSet.double("value").int("weight","count");
//================================================================================
//多重背包
bagSize = 15;
println(dataSet.dpKnapsack(bagSize,dataSet.weight,dataSet.count,dataSet.value));


dataSet = readTxt("/example/knapsack3.txt");
dataSet = dataSet.double("value").int("weight","count");
//================================================================================
//混合背包
bagSize = 15;
println(dataSet.dpKnapsack(bagSize,dataSet.weight,dataSet.count,dataSet.value));


//理财问题
dataSet = readTxt("/example/knapsack4.txt");
dataSet = dataSet.int("minmoney","maxmoney").double("interestRate");
dataSet.insertColumn(1,"value").insertColumn(2,"count").double("value").int("count");
dataSet.update("value",interestRate[0]*minmoney[0]*80);//计算基金实际收益
dataSet.update("count",maxmoney[0]/minmoney[0]);//根据基金的可购买的最大份额和最小份额算出最大的份数
//================================================================================
println(dataSet.dpKnapsack(5000,dataSet.minmoney,dataSet.count,dataSet.value));


//购物单问题
dataSet = readTxt("/example/knapsack5.txt");
dataSet = dataSet.int("price","importance","rule");
dataSet.insertColumn(1,"value").double("value");
dataSet.update("value",price[0]*importance[0]);//计算每件物品的实际价值（重要度*价格）
//================================================================================
money = 1000;
println(dataSet.dpKnapsack(money,dataSet.price,1,dataSet.value,()->{
	if(rule[i] == 0){
		if( price[i] <= money){
			return true;
		}
	}else{
		k = rule[i];
		if(price[i]+price[k]<=money){
			return true;
		}
	}
	return false;
}));
